package com.example.zzj.ziwuyundemo.fragment;


import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;

import com.example.zzj.ziwuyundemo.R;
import com.example.zzj.ziwuyundemo.activity.ReplyActivity;
import com.example.zzj.ziwuyundemo.activity.SiteActivity;
import com.example.zzj.ziwuyundemo.activity.StateQueryActivity;

import butterknife.ButterKnife;
import butterknife.InjectView;

/**
 * Created by zzj on 2016/11/22.
 */

public class HomeFragment extends Fragment implements View.OnClickListener {

    @InjectView(R.id.rl_reaction)
    RelativeLayout rlReaction;
    @InjectView(R.id.rl_state)
    RelativeLayout rlState;
    @InjectView(R.id.rl_state_query)
    RelativeLayout rl_state_query;

    private Intent intent;
    private String id;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_home, container, false);
        ButterKnife.inject(this, view);
        initView();
        initData();
        return view;
    }

    private void initView() {
        intent = getActivity().getIntent();
        id = intent.getStringExtra("id");
    }

    private void initData() {
        rlReaction.setOnClickListener(this);
        rlState.setOnClickListener(this);
        rl_state_query.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.rl_reaction:
                intent = new Intent(getActivity(), ReplyActivity.class);
                intent.putExtra("userId",id);
                startActivity(intent);
                break;
            case R.id.rl_state:
                intent = new Intent(getActivity(), SiteActivity.class);
                intent.putExtra("userId",id);
                startActivity(intent);
                break;
            case R.id.rl_state_query:
                intent =new Intent(getActivity(),StateQueryActivity.class);
                intent.putExtra("userId",id);
                startActivity(intent);
                break;
        }
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.reset(this);
    }

}
